package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	[SWF(width = "800", height = "600", backgroundColor = "0x66ccff", frameRate="60")]
	public class Container3d extends Sprite
	{

		private var sprite:Sprite;
		private var n:Number = 0;
		public function Container3d()
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.addEventListener(Event.RESIZE,onResize);
			sprite = new Sprite();
			
			for (var i:int = 0; i < 100; i++) 
			{
				var tf:TextField = new TextField();
				tf.defaultTextFormat = new TextFormat("黑体",40);
				tf.text = String.fromCharCode(65+Math.floor(Math.random()*25));
				tf.selectable = false;
				tf.x = Math.random()*300-150;
				tf.y = Math.random()*300-150;
				tf.z = Math.random()*1000;
				sprite.addChild(tf);
			}
			
			addChild(sprite);
			addEventListener(Event.ENTER_FRAME,onEnterFrame);
			stage.addEventListener(MouseEvent.MOUSE_MOVE,onMove);
			
		}
		
		protected function onMove(event:MouseEvent):void
		{
			root.transform.perspectiveProjection.projectionCenter = new Point(mouseX,mouseY);
		}
		
		protected function onEnterFrame(event:Event):void
		{
			sprite.x = stage.stageWidth/2+Math.cos(n)*200;
			sprite.y = stage.stageHeight/2+Math.sin(n)*200;
			n+=0.05;
		}
		
		protected function onResize(event:Event):void
		{
			sprite.y = stage.stageHeight/2;
		}		
		
	}
}